package managedbeans;

import entities.Forumposts;
import java.io.Serializable;
import java.util.ArrayList;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import utils.dataaccess.DBInterface;


@ManagedBean(name="searchBean")
@SessionScoped
public class SearchBean extends GenericForumBean implements Serializable {

    private String searchPattern = "Search";
    private ArrayList<Forumposts> foundPosts;

    public SearchBean() {
    }
   
    public void searchPosts() {
         foundPosts = DBInterface.getPosts(searchPattern);
    }

    public String getThreadName(int threadID){
        return DBInterface.getThreadById(threadID).getName();
    }

    public String showThread(int threadID){
        currentThread = DBInterface.getThreadById(threadID);
        setCurrentThread(currentThread);
        setCurrentBlock(currentThread.getBid());
        return "post.xhtml?faces-redirect=true";
    }

    public String getSearchPattern() {
        return searchPattern;
    }

    public void setSearchPattern(String searchPattern) {
        this.searchPattern = searchPattern;
    }

    public ArrayList<Forumposts> getFoundPosts() {
        return foundPosts;
    }

    public void setFoundPosts(ArrayList<Forumposts> foundPosts) {
        this.foundPosts = foundPosts;
    }
    
    
    
}
